{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">编辑</h3>

	<table class="layui-table">

		<tr>
			<td class="layui-td-gray">材料名称<font>*</font></td>
			<td>
				<input type="text" name="name" lay-verify="required" {notempty name="$detail.name"}value="{$detail.name}"{else/}value=""{/notempty} autocomplete="off" placeholder="请输入" class="layui-input">
			</td>
			<td class="layui-td-gray">排序<font>*</font></td>
			<td>
				<input type="text" name="sort" lay-verify="required" {notempty name="$detail.sort"}value="{$detail.sort}"{else/}value="0"{/notempty} autocomplete="off" placeholder="请输入" class="layui-input">
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn"><i class="layui-icon"></i>样表</button></td>
			<td colspan="5" style="line-height:inherit">
				<div class="layui-row" id="fileBox">
					<input type="hidden" id="fileBoxInput" name="sample_table" value="{notempty name='$detail.sample_table'}{$detail.sample_table}{/notempty}">
					{notempty name="$detail.sample_table"}
					{volist name="$detail.sample_tableArray" id="vo"}
					<div class="layui-col-md4" id="fileItem{$vo.id}">
						<div class="file-card">
							<i class="file-icon iconfont icon-renwuguanli"></i>
							<div class="file-title">{$vo.name}</div>
							<div class="file-tool">
								<a href="{$vo.filepath}" download="{$vo.name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
								<i class="btn-delete iconfont icon-shanchu red" data-id="{$vo.id}" title="删除" style="font-size: 14px;">删除</i>
							</div>
						</div>
					</div>
					{/volist}
					{/notempty}
				</div>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn1"><i class="layui-icon"></i>空表</button></td>
			<td colspan="5" style="line-height:inherit">
				<div class="layui-row" id="fileBox1">
					<input type="hidden" id="fileBox1Input" name="empty_table" value="{notempty name='$detail.empty_table'}{$detail.empty_table}{/notempty}">
					{notempty name="$detail.empty_table"}
					{volist name="$detail.empty_tableArray" id="vo"}
					<div class="layui-col-md4" id="fileItem{$vo.id}">
						<div class="file-card">
							<i class="file-icon iconfont icon-renwuguanli"></i>
							<div class="file-title">{$vo.name}</div>
							<div class="file-tool">
								<a href="{$vo.filepath}" download="{$vo.name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
								<i class="btn-delete iconfont icon-shanchu red" data-id="{$vo.id}" title="删除" style="font-size: 14px;">删除</i>
							</div>
						</div>
					</div>
					{/volist}
					{/notempty}
				</div>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray"><button type="button" class="layui-btn layui-btn-sm" id="uploadBtn2"><i class="layui-icon"></i>材料模板</button></td>
			<td colspan="5" style="line-height:inherit">
				<div class="layui-row" id="fileBox2">
					<input type="hidden" id="fileBox2Input" name="template" value="{notempty name='$detail.template'}{$detail.template}{/notempty}">
					{notempty name="$detail.template"}
					{volist name="$detail.templateArray" id="vo"}
					<div class="layui-col-md4" id="fileItem{$vo.id}">
						<div class="file-card">
							<i class="file-icon iconfont icon-renwuguanli"></i>
							<div class="file-title">{$vo.name}</div>
							<div class="file-tool">
								<a href="{$vo.filepath}" download="{$vo.name}" target="_blank" title="下载查看" style="font-size: 14px;">下载</a>
								<i class="btn-delete iconfont icon-shanchu red" data-id="{$vo.id}" title="删除" style="font-size: 14px;">删除</i>
							</div>
						</div>
					</div>
					{/volist}
					{/notempty}
				</div>
			</td>
		</tr>

	</table>

	<div class="py-3">
		<input type="hidden" name="id" {notempty name='$detail.id'}value="{$detail.id}"{/notempty}>
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool','oaTool'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,laydate = layui.laydate,oaTool = layui.oaTool;

		oaTool.addFile({exts:'png|jpg|gif|jpeg|doc|docx|ppt|pptx|xls|xlsx|pdf'});
		oaTool.addFile({btn:'uploadBtn1',exts:'png|jpg|gif|jpeg|doc|docx|ppt|pptx|xls|xlsx|pdf',box: `fileBox1`});
		oaTool.addFile({btn:'uploadBtn2',exts:'png|jpg|gif|jpeg|doc|docx|ppt|pptx|xls|xlsx|pdf',box: `fileBox2`});

		//监听提交
		form.on('submit(webform)', function(data){
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					setTimeout(function () {
						parent.location.reload();
					}, 1000);
				}
			}
			tool.post("/matter/general_material/add", data.field, callback);
			return false;
		});

	}
</script>
{/block}
<!-- /脚本 -->